# 测试@property
class Employee:

    def __init__(self, name, salary):
        self.name = name
        self.__salary = salary

    @property  # 相当于salary属性的getter方法
    def salary(self):
        print("月薪为{0},年薪为{1}".format(self.__salary, (12 * self.__salary)))
        return self.__salary;

    @salary.setter
    def salary(self, salary):  # 相当于salary属性的setter方法
        if (0 < salary < 1000000):
            self.__salary = salary
        else:
            print("薪水录入错误！只能在0-1000000之间")

    __age = 18

    @property
    def age(self):
        print("年龄为：", self.__age)
    @age.setter
    def age(self, age):
        if (0 < age < 100):
            self.__age = age
        else:
            print("年龄录入错误！只能在0-100之间")

emp1 = Employee("高淇", 100)
print(emp1.salary)
# 月薪为100,年薪为1200
# 100

emp1.salary = -200
# 薪水录入错误！只能在0-1000000之间

emp1.age = 100
# 年龄录入错误！只能在0-100之间
